package logic

import (
	"api/model/mysql"
	"context"

	"house_srv/house"
	"house_srv/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type UpdateUserLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUpdateUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateUserLogic {
	return &UpdateUserLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *UpdateUserLogic) UpdateUser(in *house.UpdateUserRequest) (*house.UpdateUserResponse, error) {
	// todo: add your logic here and delete this line

	var user mysql.User

	mysql.DB.Find(&user)

	m := mysql.User{
		Mobile:      in.Mobile,
		Name:        in.Name,
		IdCord:      in.IdCord,
		IdCordFront: in.IdCordFront,
		IdCordBack:  in.IdCordBack,
	}

	mysql.DB.Create(&m)

	return &house.UpdateUserResponse{
		Id: int64(m.ID),
	}, nil
}
